#include "ptmr_config.h"
#include "sdk_project_config.h"
#include "update.h"
#include "ptmr.h"


#define PTMR_INST (0)

uint32_t system_tick_ms = 1;

void sys_time_set(uint64_t* time)
{
	if(system_tick_ms == 0)
	{
		*time = 1;
		return;
	}
	*time = system_tick_ms;
}

void pTMR0_Ch0_IRQHandler(void)
{
    pTMR_DRV_ClearInterruptFlagTimerChannels(PTMR_INST, pTMR0_CH0);
    /* Note: Debug output inserted into interrupt routine for demo clarity. Might introduce delay. */
    update_uart_rx_timer_isr();
    system_tick_ms++;
}


void pTMR_init(void)
{
    pTMR_DRV_Init(PTMR_INST,&PTMR_Config);
    pTMR_DRV_InitChannel(PTMR_INST, pTMR0_CH0, &ptmr_channel_0);
    pTMR_DRV_StartTimerChannels(PTMR_INST, pTMR0_CH0);
}

void pTMR_DeInit(void)
{
		pTMR_DRV_Deinit(PTMR_INST);
}


